package org.example;

import org.example.vo.LoginProperties;
import org.example.web.LoginInterceptor;
import org.example.web.PowerIntercepto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Hello world!
 *
 */
@AutoConfiguration
@ComponentScan("org.example")
@ConditionalOnProperty(prefix = "login",name = "enable")
public class LoginApp implements WebMvcConfigurer {

    @Autowired
    LoginInterceptor loginInterceptor;
    @Autowired
    LoginProperties loginProperties;
    @Autowired
    PowerIntercepto powerIntercepto;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**");
        registry.addInterceptor(powerIntercepto).addPathPatterns(loginProperties.getInterceptorPath());
    }
}
